﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package com.fminutes.vinciNet {
    import flash.events.*;
    import flash.utils.*;
    import flash.display.*;
    import flash.external.*;

    public class Platform {

        private static var instance:Platform;

        private var _getFminutesSettings:Object;
        private var _platform:String;
        private var _features:String;
        private var _streamConfig:Object;
        private var _uId:String = "";
        private var _uName:String = "";
        private var _streamFolder:String = "";
        private var _imageFolder:String = "";
        private var _taskIconFolder:String = "";
        private var _achieveIconFolder:String = "";
        private var _exchangeIconFolder:String = "";
        private var _addictedTimer:Timer;
        private var _callTime:int = 1800000;
        private var _preTime:int = 0;
        private var _keysFolder:String = "";
        private var _groupShopFolder:String = "";

        public function Platform(){
            if (instance != null){
                throw (new Error("实例化单例类出错-Platform"));
            };
            instance = this;
        }
        public static function getInstance():Platform{
            if (instance == null){
                instance = new (Platform)();
            };
            return (instance);
        }

        private function getFminutesSettings():Object{
            if (this._getFminutesSettings == null){
                if (ExternalInterface.available){
                    this._getFminutesSettings = ExternalInterface.call("Fminutes.settings");
                };
            };
            return (this._getFminutesSettings);
        }
        public function set platform(_arg1:String):void{
            this._platform = _arg1;
        }
        public function get platform():String{
            if (this._platform){
                return (this._platform);
            };
            this._getFminutesSettings = this.getFminutesSettings();
            if (this._getFminutesSettings == null){
                return ("lw_en");
            };
            return (this._getFminutesSettings["namespace"]);
        }
        private function getValue(_arg1:String):Object{
            var _local2:Object;
            this._getFminutesSettings = this.getFminutesSettings();
            if (this._getFminutesSettings == null){
                return (null);
            };
            _local2 = this._getFminutesSettings["features"];
            return (_local2[_arg1]);
        }
        public function get features():String{
            return (this._features);
        }
        public function set features(_arg1:String):void{
            this._features = _arg1;
        }
        public function get stream():Boolean{
            if (this.features != null){
                if (this.features.search("stream") >= 0){
                    return (true);
                };
                return (false);
            };
            var _local1:Object = this.getValue("stream");
            if ((((_local1 == 0)) || ((_local1 == "false")))){
                return (false);
            };
            return (((_local1) || (false)));
        }
        public function get fanenable():Boolean{
            if (this.features != null){
                if (this.features.search("fanenable") >= 0){
                    return (true);
                };
                return (false);
            };
            var _local1:Object = this.getValue("fanenable");
            if ((((_local1 == 0)) || ((_local1 == "false")))){
                return (false);
            };
            return (((_local1) || (false)));
        }
        public function get neighbourEnable():Boolean{
            if (this.features != null){
                if (this.features.search("neighbour") >= 0){
                    return (true);
                };
                return (false);
            };
            var _local1:Object = this.getValue("neighbour");
            if ((((_local1 == 0)) || ((_local1 == "false")))){
                return (false);
            };
            return (((_local1) || (false)));
        }
        public function get creditEnable():Boolean{
            if (this.features != null){
                if (this.features.search("credits") >= 0){
                    return (true);
                };
                return (false);
            };
            var _local1:Object = this.getValue("credits");
            if ((((_local1 == 0)) || ((_local1 == "false")))){
                return (false);
            };
            return (true);
        }
        public function get freegiftEnable():Boolean{
            if (this.features != null){
                if (this.features.search("freegift") >= 0){
                    return (true);
                };
                return (false);
            };
            var _local1:Object = this.getValue("freegift");
            if ((((_local1 == 0)) || ((_local1 == "false")))){
                return (false);
            };
            return (true);
        }
        public function get autoStream():int{
            if (this.features != null){
                if (this.features.search("autoStream") >= 0){
                    return (2);
                };
                return (0);
            };
            var _local1:* = this.getValue("autoStream");
            if (!_local1){
                return (0);
            };
            trace(_local1);
            return (int(_local1));
        }
        public function get hiddenStream():int{
            if (this.features != null){
                if (this.features.search("hiddenStream") >= 0){
                    return (2);
                };
                return (0);
            };
            var _local1:* = this.getValue("hiddenStream");
            if (!_local1){
                return (0);
            };
            return (int(_local1));
        }
        public function setStreamConfig(_arg1:Object):void{
            this._streamConfig = _arg1;
        }
        public function setUser(_arg1:String, _arg2:String):void{
            this._uId = _arg1;
            this._uName = _arg2;
        }
        public function isSetName():Boolean{
            if (this._uId == ""){
                return (false);
            };
            return (true);
        }
        public function setStreamFolder(_arg1:String):void{
            this._streamFolder = _arg1;
        }
        public function setImageFolder(_arg1:String):void{
            this._imageFolder = _arg1;
        }
        public function setTaskIconFolder(_arg1:String):void{
            this._taskIconFolder = _arg1;
        }
        public function getStreamText(_arg1:String):String{
            var _local2:Object;
            if (this._streamConfig == null){
                return (null);
            };
            for each (_local2 in this._streamConfig) {
                if (_local2["ID"] == _arg1){
                    return (_local2["gameContent"]);
                };
            };
            return (null);
        }
        public function getStreamImg(_arg1:String, _arg2:Array=null):String{
            var _local3:Object;
            var _local4:String;
            if (this._streamConfig == null){
                return (null);
            };
            for each (_local3 in this._streamConfig) {
                if (_local3["ID"] == _arg1){
                    _local4 = _local3["media"];
                    _local4 = this.replaceArg(_local4, _arg2);
                    return ((this._streamFolder + _local4));
                };
            };
            return (null);
        }
        public function getAchieveIcon(_arg1:String):String{
            return ((this._achieveIconFolder + _arg1));
        }
        public function getExchageIconFolder(_arg1:String):String{
            return ((this._exchangeIconFolder + _arg1));
        }
        public function publishStream(_arg1:String, _arg2:Array=null, _arg3:Boolean=false):void{
            var _local4:Object;
            var _local5:Object;
            var _local6:Object;
            var _local7:Array;
            var _local8:String;
            var _local9:Array;
            var _local10:int;
            var _local11:String;
            if (this._streamConfig == null){
                return;
            };
            for each (_local4 in this._streamConfig) {
                if (_local4["ID"] == _arg1){
                    _local5 = {};
                    _local5["feedId"] = _local4["feedID"];
                    _local5["isShare"] = _local4["isShare"];
                    _local6 = {};
                    _local6["name"] = this.replaceArg(_local4["name"], _arg2);
                    _local6["description"] = this.replaceArg(_local4["description"], _arg2);
                    _local7 = [];
                    _local9 = (_local4["media"] as String).split(",");
                    _local10 = 0;
                    while (_local10 < _local9.length) {
                        _local8 = this.replaceArg(_local9[_local10], _arg2);
                        _local7.push({
                            src:(this._streamFolder + _local8),
                            href:""
                        });
                        _local10++;
                    };
                    _local6["media"] = _local7;
                    _local5["attachment"] = _local6;
                    _local5["action"] = [{
                        text:_local4["action"],
                        href:""
                    }];
                    _local5["user_message_prompt"] = _local4["user_message_prompt"];
                    _local5["user_message"] = _local4["user_message"];
                    if (_arg3){
                        _local5["isHidden"] = true;
                    };
                    _local11 = (("Fminutes." + this.platform) + ".publishStream");
                    if (ExternalInterface.available){
                        ExternalInterface.call(_local11, _local5);
                        trace(_local11, _local5);
                    };
                    return;
                };
            };
        }
        private function replaceArg(_arg1:String, _arg2:Array=null):String{
            var _local4:int;
            var _local5:String;
            var _local6:RegExp;
            var _local3:String = _arg1.replace(/\{user\}/g, this._uName);
            if (_arg2 != null){
                _local4 = 0;
                while (_local4 < _arg2.length) {
                    _local5 = (("\\{" + _local4) + "\\}");
                    _local6 = new RegExp(_local5, "g");
                    _local3 = _local3.replace(_local6, _arg2[_local4]);
                    _local4++;
                };
            };
            return (_local3);
        }
        public function addNeighbour(_arg1:String=null):void{
            var _local2 = ".addNeighbour";
            if (!this.neighbourEnable){
                _local2 = ".sendInvitation";
            };
            var _local3:String = (("Fminutes." + this.platform) + _local2);
            if (ExternalInterface.available){
                if (_arg1 == null){
                    ExternalInterface.call(_local3);
                    trace(_local3);
                } else {
                    ExternalInterface.call(_local3, _arg1);
                    trace(_local3, _arg1);
                };
            };
        }
        public function gotoIpadUrl(_arg1:String=null):void{
            var _local2 = "";
            if (!_arg1){
                _local2 = ".invitationAward";
            } else {
                _local2 = _arg1;
            };
            var _local3:String = (("Fminutes." + this.platform) + _local2);
            if (ExternalInterface.available){
                ExternalInterface.call(_local3);
                trace(_local3);
            };
        }
        public function addCredits():void{
            var _local1 = (("Fminutes." + this.platform) + ".addCredits");
            if (ExternalInterface.available){
                ExternalInterface.call(_local1);
                trace(_local1);
            };
        }
        public function gotoQQxyHome(_arg1:String):void{
            var _local2 = (("Fminutes." + this.platform) + ".toFriendHome");
            if (ExternalInterface.available){
                ExternalInterface.call(_local2, _arg1);
                trace(_local2, _arg1);
            };
        }
        public function startAddicted(_arg1:Stage):void{
            if (this._addictedTimer == null){
                this._addictedTimer = new Timer(60000);
                this._addictedTimer.addEventListener(TimerEvent.TIMER, this.onTimer);
                this._addictedTimer.start();
                this._preTime = getTimer();
                _arg1.addEventListener(MouseEvent.CLICK, this.onClick);
            };
        }
        private function onTimer(_arg1:TimerEvent):void{
            if ((getTimer() - this._preTime) >= this._callTime){
                this.addicted();
                this._addictedTimer.stop();
            };
        }
        private function onClick(_arg1:MouseEvent):void{
            this._preTime = getTimer();
        }
        public function addicted():void{
            var _local1 = (("Fminutes." + this.platform) + ".addicted");
            if (ExternalInterface.available){
                ExternalInterface.call(_local1);
                trace(_local1);
            };
        }
        public function gotoFreeGift(_arg1:String=null):void{
            var _local2 = (("Fminutes." + this.platform) + ".sendFreeGift");
            if (ExternalInterface.available){
                if (_arg1 == null){
                    ExternalInterface.call(_local2);
                    trace(_local2);
                } else {
                    ExternalInterface.call(_local2, _arg1);
                    trace(_local2, _arg1);
                };
            };
        }
        public function joinFan():void{
            var _local1 = (("Fminutes." + this.platform) + ".popBecomeFan");
            if (ExternalInterface.available){
                ExternalInterface.call(_local1);
                trace(_local1);
            };
        }
        public function buy(_arg1:String):void{
            var _local2 = "Fminutes.Payment.openPayment";
            if (ExternalInterface.available){
                ExternalInterface.call(_local2, _arg1);
                trace(_local2, _arg1);
            };
        }
        public function get taskIconFolder():String{
            return (this._taskIconFolder);
        }
        public function get imageFolder():String{
            return (this._imageFolder);
        }
        public function setAchieveIconFolder(_arg1:String):void{
            this._achieveIconFolder = _arg1;
        }
        public function setKeysFolder(_arg1:String):void{
            this._keysFolder = _arg1;
        }
        public function getkeySwfbyName(_arg1:String):String{
            return (((this._keysFolder + _arg1) + ".swf"));
        }
        public function setGroupShopFolder(_arg1:String):void{
            this._groupShopFolder = _arg1;
        }
        public function getGroupShopPicURL(_arg1:String):String{
            return ((this._groupShopFolder + _arg1));
        }
        public function setExchangeIconFolder(_arg1:String):void{
            this._exchangeIconFolder = _arg1;
        }

    }
}//package com.fminutes.vinciNet 
